<?php
// Sample shortcode [rev_slider foo="foo-value"]
function bartag_func( $atts, $content = null ) {
   extract( shortcode_atts( array(
      'foo' => 'something',
      'bar' => 'something else',
   ), $atts ) );
   
   $content = wpb_js_remove_wpautop($content); // fix unclosed/unwanted paragraph tags in $content
   return "foo = {$foo}";
}
add_shortcode( 'bartag', 'bartag_func' );

/* Register shortcode with Visual Composer */
wpb_map( array(
   "name" => __("Bar tag test"),
   "base" => "bartag",
   "class" => "",
   "controls" => "full",
   "category" => __('Content'),
   'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
   'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
   "params" => array(
      array(
         "type" => "textfield",
         "holder" => "div",
         "class" => "",
         "heading" => __("Text"),
         "param_name" => "foo",
         "value" => __("Default params value"),
         "description" => __("Description for foo param.")
      ),
      array(
         "type" => "colorpicker",
         "holder" => "div",
         "class" => "",
         "heading" => __("Text color"),
         "param_name" => "color",
         "value" => '#FF0000', //Default Red color
         "description" => __("Choose text color")
      ),
      array(
         "type" => "textarea_html",
         "holder" => "div",
         "class" => "",
         "heading" => __("Content"),
         "param_name" => "content",
         "value" => __("<p>I am test text block. Click edit button to change this text.</p>"),
         "description" => __("Enter your content.")
      )
   )
) );

/* ================================================================
 *
 * 
 * Class to register shortcode with TinyMCE editor
 *
 * Add to button to tinyMCE editor
 *
 */
class CactusThemeShortcodes{
	
	function __construct()
	{
		add_action('init',array(&$this, 'init'));
	}
	
	function init(){
		if(is_admin()){
			// CSS for button styling
			// wp_enqueue_style("ct_shortcode_admin_style", get_template_directory_uri() . '/inc/shortcodes/shortcodes.css');
		}

		if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
	    	return;
		}
	 
		if ( get_user_option('rich_editing') == 'true' ) {
			add_filter( 'mce_external_plugins', array(&$this, 'regplugins'));
			add_filter( 'mce_buttons_3', array(&$this, 'regbtns') );
			
			// remove a button. Used to remove a button created by another plugin
			// remove_filter('mce_buttons_3', array(&$this, 'remobtns'));
		}
	}
	
	function remobtns($buttons){
		// add a button to remove
		// array_push($buttons, 'ct_shortcode_collapse');
		return $buttons;	
	}
	
	function regbtns($buttons)
	{
	    // register shortcode buttons
		// array_push($buttons, [name]);
		// array_push($buttons, 'shortcode_button_name');
		return $buttons;
	}
	
	function regplugins($plgs)
	{
		// $plgs['shortcode_button_name'] = get_template_directory_uri() . '/inc/shortccodes/shortcode_sample.js';
		return $plgs;
	}
}

$ctshortcode = new CactusThemeShortcodes();
?>